#include "../../config.h"

#include <glibmm/i18n.h>

#include "../application.h"
#include "p_visual.h"
#include "p_macros.h"

namespace gpyp {
namespace pref {

//========================
// Visual
#define GENERAL (app.conf().general())
Visual::Visual(Application &app, Gtk::Window &parent) :
  Gtk::VBox                (false, 2),
  color_positive_          (app, parent, GENERAL->color_positive()),
  color_negative_          (app, parent, GENERAL->color_negative()),
  color_unimportant_       (app, parent, GENERAL->color_unimportant()),
  tooltip_color_bg_        (app, parent, GENERAL->tooltip()->color_bg(),     true),
  tooltip_color_fg_        (app, parent, GENERAL->tooltip()->color_fg(),     true),
  tooltip_color_fr_        (app, parent, GENERAL->tooltip()->color_fr(),     true),
  tooltip_color_bg_sel_    (app, parent, GENERAL->tooltip()->color_bg_sel(), true),
  tooltip_color_fg_sel_    (app, parent, GENERAL->tooltip()->color_fg_sel(), true),
  tooltip_color_fr_sel_    (app, parent, GENERAL->tooltip()->color_fr_sel(), true),
  tooltip_enable_frame_    (_("Frame")),
  tooltip_enable_frame_sel_(_("Frame selected"))
{
  Gtk::Table *t1 = Gtk::manage(new Gtk::Table());
  TABLE_LABEL(*t1, 0, _("Positive color"));
  TABLE_LABEL(*t1, 1, _("Negative color"));
  TABLE_LABEL(*t1, 2, _("Unimportant color"));
  TABLE_LABEL(*t1, 3, _("Monospace font"));
  t1->attach(color_positive_,    1, 2, 0, 1);
  t1->attach(color_negative_,    1, 2, 1, 2);
  t1->attach(color_unimportant_, 1, 2, 2, 3);
  t1->attach(font_monospace_,    1, 2, 3, 4);
  TABLE_SPACING(*t1, 2, 2);
  t1->set_border_width(2);
  pack_start(*t1, false, false);

  Gtk::Table *t2 = Gtk::manage(new Gtk::Table());
  TABLE_LABEL(*t2, 0, _("Background"));
  TABLE_LABEL(*t2, 1, _("Text"));
  t2->attach(tooltip_enable_frame_, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::SHRINK | Gtk::FILL);
  TABLE_LABEL(*t2, 3, _("Background selected"));
  TABLE_LABEL(*t2, 4, _("Text selected"));
  t2->attach(tooltip_enable_frame_sel_, 0, 1, 5, 6, Gtk::SHRINK | Gtk::FILL, Gtk::SHRINK | Gtk::FILL);
  t2->attach(tooltip_color_bg_,     1, 2, 0, 1);
  t2->attach(tooltip_color_fg_,     1, 2, 1, 2);
  t2->attach(tooltip_color_fr_,     1, 2, 2, 3);
  t2->attach(tooltip_color_bg_sel_, 1, 2, 3, 4);
  t2->attach(tooltip_color_fg_sel_, 1, 2, 4, 5);
  t2->attach(tooltip_color_fr_sel_, 1, 2, 5, 6);
  TABLE_SPACING(*t2, 2, 2);
  t2->set_border_width(2);
  Gtk::Frame *f1 = Gtk::manage(new Gtk::Frame(_("Tooltip")));
  f1->add(*t2);
  pack_start(*f1, false, false);

  ConfMain::RefGeneral general = app.conf().general();
  general->font_monospace()->attach(font_monospace_.property_font_name());

  ConfMain::RefTooltip tooltip = general->tooltip();
  tooltip->enable_frame()    ->attach(tooltip_enable_frame_    .property_active());
  tooltip->enable_frame()    ->attach(tooltip_color_fr_        .property_sensitive());
  tooltip->enable_frame_sel()->attach(tooltip_enable_frame_sel_.property_active());
  tooltip->enable_frame_sel()->attach(tooltip_color_fr_sel_    .property_sensitive());
}

}/*pref*/
}/*gpyp*/
